package com.yanqu.road.server.logic.smallgame;

import com.yanqu.road.server.logic.smallgame.stage.WaterSortStage;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class WaterSortCreate {
    public static void main(String[] args) {
        int argsNum = 5;
        if (args.length < argsNum) {
            System.out.printf("need args num %d!%n", argsNum);
            return;
        }
        int colorNum = Integer.parseInt(args[0]);
        int deepNum = Integer.parseInt(args[1]);
        int emptyNum = Integer.parseInt(args[2]);
        int deepMax = Integer.parseInt(args[3]);
        int stageCount = Integer.parseInt(args[4]);

        List<WaterSortStage> stages = new ArrayList<>();
        for (int i = 0; i < stageCount; i++) {
            WaterSortStage stage = new WaterSortStage(colorNum, deepNum, emptyNum, deepMax);
            stage.randomInit();
            if (stage.isHaveOneFullColor()) continue;
            if (stage.solve()) {
                stages.add(stage);
            }
        }
        stages.sort(Comparator.comparing(WaterSortStage::getAnswerDeep));
        StageCSVCreate.CreateWaterSortStageConfig(stages, colorNum, emptyNum, deepNum);
        return;
    }
}
